﻿using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace Yamfinder.Service.Tests
{
    [TestClass]
    public class CryptoServiceTests
    {
        public ICryptoService GetService()
        {
            return new CryptoService();
        }


        [TestMethod]
        public void GetHashReturnsGibberish()
        {
            const string testPassword = "yamfinderisawesome";

            var service = GetService();

            var hashedValue = service.GetHash(testPassword);

            Assert.AreNotEqual(testPassword,hashedValue);
            Assert.AreNotEqual(testPassword.Length, hashedValue.Length);
            Assert.IsFalse(hashedValue.Contains(testPassword));
        }

        [TestMethod]
        public void MatchReturnsMatchBetweenHashedAndOriginalValue()
        {
            const string testPassword = "yamfinderReallyIsAwesome";

            var service = GetService();

            var hashedValue = service.GetHash(testPassword);

            Assert.IsTrue(service.Match(testPassword, hashedValue));
        }
    }
}
